/**
 * \file	ASTNode.h
 * \author	Caio Arce Nishibe (caionishibe@gmail.com)
 * \date	August, 2014
 * \brief	Abstract Syntax Tree Node header.
 */

#ifndef __AST_NODE_H
#define __AST_NODE_H

#include "Common.h"
#include "parser.tab.h"
#include "IVisitor.h"

class IVisitor;

/**
 * \brief	Abstract Syntax Tree Node 
 * \author	Caio Arce Nishibe (caionishibe@gmail.com)
 * \date	August, 2014
 */
class ASTNode
{
public:
	/**
	 * \brief Node name
	 */
	std::string name;
	/**
	 * \brief Node kind
	 */
	Kind kind;
	/**
	 * \brief Node type
	 */
	Type type;
	/**
	 * \brief Node value
	 */
	Value value;
	/**
	 * \brief Node line number declaration
	 */
	int lineNumber;	

	

	/**
	 * \brief Pointer to node parent
	 */
	ASTNode *parent;
	/**
	 * \brief Pointer to node children
	 */
	ASTNode *children;
	/**
	 * \brief Pointer to node sibling
	 */
	ASTNode *sibling;

	/**
	 * \brief	ASTNode default constructor.
	 * \details Perform default initialization of the members.
	 */
	ASTNode();

	/**
	 * \brief	ASTNode constructor.
	 * \details	Initialize members with given values.
	 * \param	name		node name. 
	 * \param	kind		node kind.
	 * \param	type		node type.
	 * \param	lineNumber	node declaration line number.
	 */
	ASTNode(std::string name, int kind, int type, int lineNumber);
	
	/**
	 * \brief	ASTNode destructor.
	 */
	~ASTNode();

	/**
	 * \brief	Add sibiling to the current node.
	 * \param	sibling	pointer to the sibling node.
	 */
	void AddSibling(ASTNode *sibling);
	
	/**
	 * \brief	Add child to the current node.
	 * \param	child	pointer to the child node.
	 */
	void AddChild(ASTNode *child);
	
	/**
	 * \brief	Call the apropriate visit function of the visitor based on the node kind.
	 * \param	visitor	Pointer to a class that implements the IVisitor interface.
	 */
	void Accept(IVisitor *visitor);

};


#endif
